package com.example.springbootproject.mianshi.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyProxy implements InvocationHandler {

    private Object obj;

    // 基于构造方法
    public MyProxy(Object o){
        this.obj = o;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("方法执行前处理逻辑");
        Object res = method.invoke(obj, args);
        System.out.println("方法执行后处理逻辑");
        return res;

    }
}
